<?php
require_once 'MDB2.php';


require_once 'LiveUser.php';

//NH_Member Calss act as the actualy use class for NH_Site.

class NH_Member{
	//Contain LiveUser Object 
	var $LUObj = null;
	var $db = null;
	var $dsn = null;
	
	//This constroct is private
	//use getInstance() get This object;
	function NH_Member() {
		//Be using DB
		$this->dsn = $GLOBALS['g_dsn']; // check if $golbal_dsn is set???
		$this->db = MDB2::connect($this->dsn);
		if (PEAR::isError($this->db)) {
			echo $this->db->getMessage() . ' ' . $this->db->getUserInfo();
		}
		$this->db->setFetchMode(MDB2_FETCHMODE_ASSOC); 
		//Be using LiveUser
		require_once("memb_conf.php");
		PEAR::setErrorHandling(PEAR_ERROR_RETURN);
		$this->LUObj = & LiveUser::singleton($conf);
		return true;
	}
	function &getInstance(){
		//sigleton pattern
		static $mem_inst;
		if(isset($mem_inst)){
			return $mem_inst;
		} else {
			$mem_inst = & new NH_Member();
			return $mem_inst;
		}
	}
	function init() {
		if (!$this->LUObj->init()) {
		    var_dump($usr->getErrors());
		    die();
		}
		return true;
	}
	//Session about manipulate Container Data;
	function addMember(&$memberInfo) {
	
	    return;
	}
	function removeMember($mid) {
	
	    return;
	}
	function modifyMember($mid) {
	
	    return;
	}
	
	//Session About Authentication
	function login($handle = '', $passwd = '', $remember = false, $auth_user_id = false) {
		return $this->LUObj->login($handle,$passwd,$remember,$auth_user_id);
	}
	function logout($direct = true) {
	    return $this->LUObj->logout($direct);
	}
	function isLoggedIn() {
	    return $this->LUObj->isLoggedIn();
	}
	function getProperty($what, $container = 'auth') {
	    return $this->LUObj->getProperty($what, $container);
	}
	//Session about permmision
	function checkRight($rights) {
	    return $this->LUObj->checkRight($rights);
	}
	function addRight($rights) {
	
	    return;
	}
	function removeRight($rights) {
	
	    return;
	}
}
?>
